using Godot;

namespace PlayerState
{
public partial class Run : Node,StateNode
{
    public void OnEnter()
    {
        GetNode<AnimatedSprite2D>("/root/Main/Player/AnimaPlayer").Animation = "run"; 

        GetNode<AudioStreamPlayer2D>("Music").Play();
    }

    public void OnExit()
    {
        GetNode<AudioStreamPlayer2D>("Music").Stop();
    }

    public void OnUpdate(float delta)
    {
        Player player = GetNode<Player>("/root/Main/Player");

        if(player.Health<0)
            player.SwitchTo("Dead");               
        else if(!player.IsRun())
            player.SwitchTo("Idle");
    }
}
}